var $ = require("../../utils/Ajax.js");
Page({
  data: {
    Id: null,

    movies: [],

    // 用户自己的信息
    UserInfor: null,

    // 是否显示修改按钮
    EditBtn: true
  },

  onShow: function(){
    var that = this;
    $.Ajax("api/uindex", "GET", {}, function (res) {
      if (res.s) {
        that.setData({
          movies: res.d.user.album,
          UserInfor: res.d.user
        })
      } else {
        wx.showToast({
          title: res.m,
          icon: 'none',
          duration: 1500
        })
      }
    });
  },

  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "个人资料"
    }) 
    this.setData({
      Id: options.Id
    })
  },

  // 点击编辑资料
  GoModify: function(){
    var UserInfor = JSON.stringify(this.data.UserInfor);
    var Movies_ = [];
    var movies = this.data.movies;
    for (var i = 0; i < movies.length;i++){
      Movies_.push(movies[i].url)
    }
    var Movies = JSON.stringify(Movies_);
    wx.navigateTo({
      url: '../GoModify/GoModify?UserInfor=' + UserInfor + "&Movies=" + Movies,
    })
  }
})